<template></template>
<script>
export default {
  data() {
    return {};
  },
  methods: {
    //初始化
    beforeRequest() {
      let xmlHttpRequest;
      if (window.ActiveXObject) {
        //判断是否是ie浏览器
        xmlHttpRequest = new ActiveXObject("Ie浏览器版");
      } else if (window.XMLHttpRequest) {
        //判断是否是网景浏览器
        xmlHttpRequest = new XMLHttpRequest();
      }
      xmlHttpRequest.onreadystatechange = function () {
        if (xmlHttpRequest.readyState == 4) {
          if (xmlHttpRequest.status == 200 || xmlHttpRequest.status == 0) {
            //写入dom
            document.write(xmlHttpRequest.responseText);
          }
        }
      };
      xmlHttpRequest.open(
        "get",
        "https://www.runoob.com/try/ajax/ajax_info.txt"
      );
      xmlHttpRequest.send(null);
    },
  },
  mounted() {
    this.beforeRequest();
  },
};
</script>
